<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="zj" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:zj="http://www.zju.edu.cn">
  <xsl:import href="../../Tk2Base/GlobalVariable.xslt"/>
  <xsl:import href="../../Tk2Base/Button.xslt"/>
  <xsl:import href="../../Tk2Base/Utility.xslt"/>
  <xsl:output method="html" indent="no"/>
  <xsl:variable name="zj:Toolkit" select="/Toolkit"/>
  <xsl:variable name="zj:Title" select="''"/>
  <xsl:template match="/">
    <table width="100%" border="0" cellspacing="0" cellpadding="6" onclick="DocOnClick()">
      <tr>
        <td class="title" style="padding: 2px">
          <table border="0" width="100%" cellspacing="0" cellpadding="0">
            <tr>
              <td class="title" style="padding: 0px">
                <xsl:call-template name="zj:PageTitle"/>
              </td>
              <td align="right">
                <img src="../images/maintitle.jpg" width="220" height="23"/>
              </td>
            </tr>
            <tr>
              <td background="../images/fix.gif" colspan="2" height="1"/>
            </tr>
          </table>
          <br/>
        </td>
      </tr>
      <tr>
        <td>
          <form name="frmData">
            <xsl:call-template name="zj:Content"/>
            <input type="hidden" name="_GUID" id="_GUID" value="{$zj:GUID}"/>
            <div id="divMaskLayer" >
              <table width="100%" border="0" cellspacing="0" cellpadding="2">
                <tr>
                  <td>
                    <xsl:call-template name="zj:Button"/>
                  </td>
                </tr>
              </table>
            </div>
          </form>
        </td>
      </tr>
    </table>
    <xsl:call-template name="zj:Script"/>
  </xsl:template>
  <xsl:template name="zj:PageTitle">
    <xsl:call-template name="zj:LittleTitle">
      <xsl:with-param name="Name" select="'Permission Configuration'"/>
    </xsl:call-template>
  </xsl:template>
  <xsl:template name="zj:Button">
    <xsl:call-template name="zj:JSButton">
      <xsl:with-param name="Name" select="' 保存'"/>
      <xsl:with-param name="JS" select="'verify(&quot;Save&quot;)'"/>
    </xsl:call-template>
    <xsl:call-template name="zj:CancelButton"/>
  </xsl:template>
  <xsl:template name="zj:Content">
    <div id="funcTree"></div>
  </xsl:template>
  <xsl:template name="zj:Script">
    <script>
      function verify(save)
      {
        var id = "<xsl:value-of select="$zj:Toolkit/QueryString/ID"/>";
        var ret = "<xsl:value-of select="$zj:Toolkit/URL/DRetURL"/>";
        var source= "<xsl:value-of select="$zj:Toolkit/Info/Source"/>";
        var suffix= "<xsl:value-of select="$zj:Toolkit/Info/PageX"/>";
        <xsl:comment>
          <![CDATA[
          var url =  "../Pages/WebSimplePage." + suffix + "?Source=" + source + "&ID=" + id + "&RetURL=" + ret;
          PostXmlData("SYS_FUNCTION,SYS_SUB_FUNC", "FN_ID;SF_ID", url, frmData._GUID.value, "");
        ]]>
        </xsl:comment>
      }


      var tagTree = '#funcTree';

      var array = <xsl:value-of select="$zj:Toolkit/SYS_FUNCTION_JSON/JSONData"/>;
      $(function(){
      $(tagTree).tree({
      checkbox: true,
      data: array,
      onClick:function(node){
      $(this).tree('toggle', node.target);
      }
      });
      });

      var firstPost = true;
      function PostXmlData(tableName, fieldID, webFile, dataSet, save) {
      if (!firstPost) {
      var msg = "数据正在提交过程中，请稍后……";
      $.messager.alert('Error Message', msg, 'warning');
      return false;
      }
      firstPost = false;
      var sendXml = GenerateTreeData(tagTree,tableName, fieldID,dataSet, save);

      AJAXPost(webFile, sendXml, onCompleted);
      }

      function onCompleted(){
      firstPost = true;
      }
    </script>
  </xsl:template>
</xsl:stylesheet>
